import ctypes as c
import os


LIB = "list.so"
PATH = __file__[:-12]

try:
	LIB = PATH +'/' + LIB
	listlib = c.cdll.LoadLibrary(LIB)
	print "ctypes loads {0} correctly".format(LIB)
except:
	raise ImportError("cannot load ctypes lib {0}".format(LIB))
	

class Node(c.Structure): pass
Node._fields_ = [("id"   , c.c_int),
		 ("data" , c.c_float),
		 ("next" , c.POINTER(Node)),
		 ("prev" , c.POINTER(Node))]

class List(c.Structure):pass
List._fields_ = [("size" , c.c_int),
		 ("head" , c.POINTER(Node)),
		 ("tail" , c.POINTER(Node))]

class Iterator(c.Structure): pass
Iterator._fields_ = [("list", c.POINTER(List)),
		     ("current", c.POINTER(Node))]

from listwrap import *

print ("List module loaded")
